Skip to content

chore: add method to return cached config value#1944

Merged
rolznz merged 4 commits intomasterfrom
chore/cache-config-get-values
Nov 29, 2025
Merged

chore: add method to return cached config value#1944
rolznz merged 4 commits intomasterfrom
chore/cache-config-get-values

Conversation

@rolznz
Copy link
Copy Markdown
Contributor

@rolznz rolznz commented Nov 26, 2025

Fixes #1943

Now with Postgres these config Gets are doing remote API calls and we need to be careful not to do too many of them.

(Just the general idea, we can apply to most of the config Gets that never change over the app's lifetime if it sounds good)

TODO:

  • review general idea
  • apply cache to existing methods

Copy link
Copy Markdown
Contributor

@bumi bumi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If that's the Go way of doing this 👍

config/config.go Outdated
return cfg.get(key, encryptionKey, cfg.db)
}

func (cfg *config) GetCached(key string, encryptionKey string) (string, error) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we even need to methods for this?
can't/shouldn't this always be cached?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True. So we delete the key from the cache when we set a new value.

@rolznz rolznz requested a review from bumi November 29, 2025 04:23
@rolznz rolznz marked this pull request as ready for review November 29, 2025 04:23
@rolznz rolznz merged commit d12ed10 into master Nov 29, 2025
11 checks passed
@rolznz rolznz deleted the chore/cache-config-get-values branch November 29, 2025 04:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

config GetRelayUrls() is called too many times

2 participants